﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Net.Http;
using System.Collections.Generic;

namespace Xinchen.SOA.UnitTests
{
    [TestClass]
    public class UnitTest1
    {
        HttpClient client = new HttpClient();
        [TestMethod]
        public void TestMethod1()
        {
            var response = client.PostAsync("http://localhost:9000/logservice/writelog", new StringContent("")).Result;

            Console.WriteLine(response);
            Console.WriteLine(response.Content.ReadAsStringAsync().Result);
        }
        [TestMethod]
        public void TestMethod2()
        {
            var parameters = new List<KeyValuePair<string, string>>();
            parameters.Add(new KeyValuePair<string, string>("msg", "1"));
            parameters.Add(new KeyValuePair<string, string>("msg1", "1"));
            var response = client.PostAsync("http://localhost:9000/logservice/writelog1", new FormUrlEncodedContent(parameters)).Result;

            Assert.IsTrue(response.Content.ReadAsStringAsync().Result == "\"11\"");
        }
        [TestMethod]
        public void TestMethod3()
        {
            var parameters = new List<KeyValuePair<string, string>>();
            parameters.Add(new KeyValuePair<string, string>("msg", "1"));
            parameters.Add(new KeyValuePair<string, string>("msg1", "1"));
            var response = client.PostAsync("http://localhost:9000/logservice/writelog2", new FormUrlEncodedContent(parameters)).Result;

            Assert.IsTrue(response.Content.ReadAsStringAsync().Result == "\"11\"");
        }
    }
}
